# 返回状态码
from django.http import HttpResponse
import json

# @param
#   state: success 或是 error ;data: 返回的数据字典dict
# @return
#   json
def ajaxResult(state, data, message):
    result = {}
    if data == None:
        data = {}
    if state == "success":
        result = {"code": 200, "message": message, "success": "true"}
        result.update(data)
    else:
        result = {"code": 401, "message": message, "success": "false"}
        result.update(data)
    return HttpResponse(json.dumps(result))
